<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>客户管理系统</title>
    <link rel="stylesheet" type="text/css" media="screen" href="css/base.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/head.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/addCustomer.css" />
</head>
<body>
<div class="mian-head">
    <div class="mian-head-mid">
        <p class="main-title">客户管理系统</p>
        <div class="mian-head-mid-r">
            <p class="main-hy" th:text="'欢迎：'+${session.myUser.name}+'管理员'"></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a th:href="@{getUserMessage(name=${session.myUser.name})}">个人信息</a></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a href="logout">退出</a></p>
        </div>
    </div>
</div>
<div class="list-mid">
    <!-- 标题 -->
    <div class="list-title">
        <div class="list-title-div"></div>
        <p>修改客户信息</p>
    </div>

    <!-- 表单 -->
    <form th:action="@{updateCustomer}" method="post" name="updateCForm" onsubmit="return checkfun3()">
        <table class="addform-table">
            <tr>
                <td class="addform-1">姓名：</td>
                <td class="addform-2"><input class="addform-input-text" type="text"  id="name" name="name" th:value="${customer.name }" readonly="readonly"/><p class="bukegg">(不可更改)</p></td>
            </tr>
            <tr>
                <td class="addform-1">负责人编号：</td>
                <td class="addform-2">
<!--                    <input class="addform-input-text" type="number"  name="user_id" th:value="${customer.user_id}"/>-->
                    <select name="user_id" class="addform-input-text" th:value="${customer.user_id}"  required="required" >
                        <option value="">--请选择--</option>
                        <option  th:each="id:${session.ids}" th:value="${id}" th:text="${id}" th:selected="${customer.user_id eq id}"></option>
<!--                        <option  th:each="id:${session.ids}" th:value="${id}" th:text="${id}"></option>-->
                    </select>
                </td>
            </tr>
            <tr>
                <td class="addform-1">创建人编号：</td>
                <td class="addform-2"><input class="addform-input-text" type="number"  name="create_id"  th:value="${customer.create_id}" readonly="readonly"/><p class="bukegg">(不可更改)</p></td>
            </tr>
            <tr>
                <td class="addform-1">行业：</td>
                <td class="addform-2"><select name="industry" class="addform-input-text">
                    <option value="餐饮" th:selected="${customer.industry eq '餐饮'}">餐饮</option>
                    <option value="房地产" th:selected="${customer.industry eq '房地产'}">房地产</option>
                    <option value="服务" th:selected="${customer.industry eq '服务'}">服务</option>
                    <option value="公益组织" th:selected="${customer.industry eq '公益组织'}">公益组织</option>
                    <option value="教育" th:selected="${customer.industry eq '教育'}">教育</option>
                    <option value="计算机" th:selected="${customer.industry eq '计算机'}">计算机</option>
                    <option value="金融" th:selected="${customer.industry eq '金融'}">金融</option>
                    <option value="政府机关" th:selected="${customer.industry eq '政府机关'}">政府机关</option>
                    <option value="农业" th:selected="${customer.industry eq '农业'}">农业</option>
                    <option value="旅游业" th:selected="${customer.industry eq '旅游业'}">旅游业</option>
                    <option value="媒体" th:selected="${customer.industry eq '媒体'}">媒体</option>
                    <option value="其他" th:selected="${customer.industry eq '其他'}">其他</option>
                </select></td>
            </tr>
            <tr>
                <td class="addform-1">等级：</td>
                <td class="addform-2">
                    <input type="radio" name="level" th:checked="${customer.level eq '普通客户'}" value="普通客户">普通客户
                    <input type="radio" name="level" th:checked="${customer.level eq 'VIP客户'}" value="VIP客户">VIP客户
                </td>
            </tr>
            <tr>
                <td class="addform-1">固定电话：</td>
                <td class="addform-2"><input class="addform-input-text" type="text"  name="phone" th:value="${customer.phone}"/></td>
            </tr>
            <tr>
                <td class="addform-1">移动电话：</td>
                <td class="addform-2"><input class="addform-input-text" type="text"  name="mobile"  th:value="${customer.mobile}"/></td>
            </tr>
            <tr>
                <td class="addform-1">地址：</td>
                <td class="addform-2"><input class="addform-input-text" type="text"  name="address" th:value="${customer.address}" /></td>
            </tr>
            <td><input name="id" type="hidden" th:value="${customer.id}"></td>

            <tr>
                <td colspan="2" class="addform-submit"> <input type="submit" value="提交" /> <a class="returnbtm" href="GetCustomerList">返回</a></td>
            </tr>

        </table>

    </form>

</div>
<script>
    function checkfun3() {

        var phone=document.forms["updateCForm"]["phone"].value;
        var mobile=document.forms["updateCForm"]["mobile"].value;


        var isphone = /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/;
        var ismobile = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
        console.log(isphone.test(phone));

        if(phone != "" && !isphone.test(phone)){
            alert("固定电话号码输入不合法");
            return false;
        }
        if(mobile != "" && !ismobile.test(mobile)){
            alert("移动电话号码输入不合法");
            return false;
        }
    }
</script>
</body>
</html>